<?php
quanli_require('core/cellBox.php');

class entity extends cellBox{
	protected $_identifier;
	
	function __construct($identifier){
		$this->_identifier = is_null($identifier) ? null : trim($identifier);
		if ($this->_identifier === '')
			throw new Exception('参数值不能为空');
		$this->_fields['uuid'] = null;
		$this->_fields['timeStamp'] = null;
	}
	public function getIdentifier(){
    	return $this->_identifier;
    }
	function is_persisted(){
		return isset($this->_fields['uuid']) && !is_null($this->_fields['uuid']);
	}
	function markPersisted(){
		$this->_fields['uuid'] = make_uuid();
        if (!isset($this->_fields['createTime']) || empty($this->_fields['createTime'])) {
            $this->_fields['createTime'] = date(G_DEFAULT_DATETIME_FORMAT);
        }
		$this->_fields['timeStamp'] = date(G_DEFAULT_DATETIME_FORMAT);
	}
	function unmarkPersisted(){
		$this->_fields['uuid'] = null;
		unset($this->_fields['createTime']);
		unset($this->_fields['timeStamp']);
		//$this->_fields['timeStamp'] = null;
	}
}